//引入二次封装的axios
import request from "@/util/request.ts";
// @ts-ignore
import type {
    HospitalDetail,
    DepartmentResponseData,
    LoginData,
    UserLoginResponseData,
    WXLoginResponseData,
    DoctorResponseData, HospitalWorkData, UserResponseDate, DoctorInfoData
} from "@/api/hospital/type.ts";

//枚举请求地址
enum API {
    HOSPITALDETAIL_URL = '/hosp/hospital/',
    //获取某个医院科室的信息
    HOSPITALDEPARTMENT_URL = '/hosp/hospital/department/',
    //获取验证码接口
    GETUSERCODE_URL = '/sms/send/',
    //用户登录接口
    UDERLOGIN_URL = 'user/login',
    //获取微信扫码登陆的参数
    WXLOGIN_URL = '/user/weixin/getLoginParam/',
    //获取某一个医院的某一个科室预约挂号数据
    HSOSPITALWORK_URL = '/hosp/hospital/auth/getBookingScheduleRule/',
    //获取某一个科室某一天相应医生排班的数据
    HOSPITALDOCTOR_URL = '/hosp/hospital/auth/findScheduleList/',
    //获取某一个账号下就诊人的信息
    GETUSER_URL = '/user/patient/auth/findAll',
    //获取排班医生的信息
    GETDOCTOR_URL = '/hosp/hospital/getSchedule/'
}

//获取医院详情的接口
export const reqHospitalDetail = (hoscode: string) =>
    request.get<any, HospitalDetail>(API.HOSPITALDETAIL_URL + hoscode)

//获取医院科室的信息
export const reqHospitalDepartment = (hoscode: string) =>
    request.get<any, DepartmentResponseData>(API.HOSPITALDEPARTMENT_URL + hoscode)

//获取用户登陆时的验证码
export const reqUserCode = (phone: string) =>
    request.get<any, any>(API.GETUSERCODE_URL + phone)

//获取用户登录的信息
export const reqUserLogin = (data: LoginData) =>
    request.post<any, UserLoginResponseData>(API.UDERLOGIN_URL, data)

//获取微信扫码登录生成二维码需要参数接口
export const reqWxLogin = (wxRedirectUri: string) =>
    //后台接口问题，固定了返回的url为他们自己的服务上的页面，本机访问会出现跨域的异常，无法登录成功
    request.get<any, WXLoginResponseData>(API.WXLOGIN_URL + `?wxRedirectUri=${wxRedirectUri}`)
//获取某医院某科室的预约挂号信息
export const reqHospitalWork = (page: number, limit: number, hoscode: string, depcode: string) =>
    request.get<any, HospitalWorkData>(API.HSOSPITALWORK_URL + `${page}/${limit}/${hoscode}/${depcode}`)

//获取某一个科室某一天相应医生排班的数据
export const reqHospitalDoctor = (hoscode: string, depcode: string, workDate: string) =>
    request.get<any, DoctorResponseData>(API.HOSPITALDOCTOR_URL + `${hoscode}/${depcode}/${workDate}`)

//获取就诊人信息
export const reqGetUser = ()=>
    request.get<any,UserResponseDate>(API.GETUSER_URL)

//获取挂号医生的信息
export const reqDoctorInfo =(scheduleId:string)=>
    request.get<any,DoctorInfoData>(API.GETDOCTOR_URL+`${scheduleId}`)